/**
 * @Title: index.js
 * @Description: index
 * @author: Fanchao
 * @date: 2020/8/29 9:21 下午
 * @version V1.0
 */
import React from "react";
import styles from "@/pages/teaching-quality/my-evaluations/index.less";
import SectionTitle from "components/SectionTitle";
import { Col, Row, Table } from "antd";
import { connect } from "umi";
// import LineCharts from '@/pages/teaching-quality/my-evaluations/components/line-charts';

const MyEvaluations = ({ myEvaluations: { dataSource, reqPageInfo, userData, lineData }, dispatch, loading }) => {
    const columns = [
        {
            title: "教员姓名",
            dataIndex: "teacherRealName",
            align: "left"
        },
        {
            title: "教员编号",
            dataIndex: "evaluateObjectNo",
            align: "left"
        },
        {
            title: "当时职称",
            dataIndex: "historyTitle",
            align: "left"
        },
        {
            title: "课程名称",
            dataIndex: "course",
            align: "left"
        },
        {
            title: "教学班",
            dataIndex: "classNo",
            align: "left"
        },
        {
            title: "学年",
            dataIndex: "schoolYear",
            align: "left"
        },
        {
            title: "学期",
            dataIndex: "semester",
            align: "left"
        },
        {
            title: "专家评价分数",
            dataIndex: "expertScore",
            align: "left"
        },
        {
            title: "学生评价分数",
            dataIndex: "studentScore",
            align: "left"
        },
        {
            title: "评价分数",
            dataIndex: "evaluateScore",
            align: "left"
        },
        {
            title: "评价结果",
            dataIndex: "evaluateResult",
            align: "left"
        },
        {
            title: "单位排名",
            dataIndex: "departmentRank",
            align: "left"
        }
    ];
    const searchByPageNumber = (pageNumber) => {
        dispatch({
            type: "teachers/getDataSource",
            payload: {
                reqPageInfo: {
                    pageNumber,
                    pageSize: reqPageInfo.pageSize
                }
            }
        });
    };
    return (
        <div className={styles.detailContainer}>
            <div className={styles.detailHeader}>
                <SectionTitle title={"教员信息"}/>
                <Row>
                    <Col span={4}>
                        <span className={styles.label}>教员姓名：</span>
                        <span className={styles.value}>{userData.teacherRealName}</span>
                    </Col>
                    <Col span={4}>
                        <span className={styles.label}>教员编号：</span>
                        <span className={styles.value}>{userData.credentialsNo}</span>
                    </Col>
                    <Col span={4}>
                        <span className={styles.label}>职称：</span>
                        <span className={styles.value}>{userData.teacherTitle}</span>
                    </Col>
                </Row>
            </div>
            {/*<div className={styles.detailEcharts}>*/}
            {/*    <SectionTitle title={'教员评价数据图例'}/>*/}
            {/*    <LineCharts lineData={lineData}/>*/}
            {/*</div>*/}
            <div className={styles.detailTableContainer}>
                <SectionTitle title={"课程评价详情"}/>
                <Table
                    bordered={false} // 是否有边框
                    rowKey='evaluateObjectId' // 唯一key值
                    loading={loading} // 加载动画
                    columns={columns} // 表头
                    dataSource={dataSource.contentList}
                    pagination={{
                        total: dataSource.totalElements,// 总记录数
                        defaultPageSize: 10, // 默认显示条数
                        showQuickJumper: true, // 快速跳转
                        showSizeChanger: true, // 一页展示数据条数
                        onChange: (pageNumber) => searchByPageNumber(pageNumber),
                        showTotal: () => {
                            return `共${dataSource.totalElements}条`;
                        }
                    }}
                />
            </div>
        </div>
    );
};

export default connect(({ myEvaluations, dispatch, loading }) => ({
    myEvaluations,
    dispatch,
    loading: loading.effects["myEvaluations/getDataSource"]
}))(MyEvaluations);
